class JobsController < ApplicationController
	before_filter :login_required, :except => [:show]

  def show
    @job = Job.find(params[:id])
  end

  def new
    @job = Job.new
  end

  def edit
    @job = Job.find(params[:id])
  end

  def create
    @job = Job.new(params[:job])

    respond_to do |format|
      if @job.save
        flash[:notice] = 'Job was successfully created.'
        format.html { redirect_to job_url(@job) }
        format.xml  { head :created, :location => job_url(@job) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @job.errors.to_xml }
      end
    end
  end

  def update
    @job = Job.find(params[:id])

    respond_to do |format|
      if @job.update_attributes(params[:job])
        flash[:notice] = 'Job was successfully updated.'
        format.html { redirect_to job_url(@job) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @job.errors.to_xml }
      end
    end
  end

  def destroy
    @job = Job.find(params[:id])
    @job.destroy
  	redirect_to :controller => :company, :action => :careers
  end
end
